@use "../../assets/scss/mixins/base" as mx;

html {
  box-sizing: border-box;
}

:root {
  --sun-color: #ffbb10;
  --sky-color-1: #fbd788;
  --sky-color-2: #ffefc0;
  --sky-color-3: #e8bf62;
  --land-color-1: #62b144;
  --land-color-2: #3d9339;
  --grass-color-1: #37913b;
  --grass-color-2: #8bc435;
  --brick-color-1: #d58256;
  --brick-color-2: #cd7555;
  --wood-color-1: #623b39;
  --wood-color-2: #472a2a;
  --wood-color-3: #2e1d1d;
  --wood-color-4: #000000;
  --window-color-1: #e3e1e1;
  --window-color-2: #000000;
  --window-color-3: #ffffff;
  --mill-top-color: #c0c0c0;
  --mill-bottom-color-1: #8f3c31;
  --mill-bottom-color-2: #9c4b3d;
  --dome-color: #ffffff;
  --blade-color-1: #fd903d;
  --blade-color-2: #be684f;
  --window-move-time: 2s;
  --land-slide-time: 2s;
  --blades-spin-time: 6s;
}

*,
*::before,
*::after {
  box-sizing: inherit;
  margin: 0;
  padding: 0;
}

body {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

.scene {
  @include mx.middle(540px, 540px);
  border-radius: 50%;
  background: radial-gradient(
      farthest-side at 135px 340px,
      var(--sky-color-2) 135px,
      transparent 135px
    ),
    radial-gradient(
      farthest-side at 405px 300px,
      var(--sky-color-1) 140px,
      transparent 135px
    ),
    linear-gradient(
      to bottom,
      var(--sky-color-1) 320px,
      var(--sky-color-2) 320px
    );
  &::before {
    @include mx.pseudo();
    inset: 0;
    border-radius: 50%;
    background: linear-gradient(
      to bottom,
      transparent 490px,
      var(--sky-color-3) 490px,
      var(--sky-color-3) 510px,
      var(--sky-color-1) 510px
    );
  }
  * {
    position: absolute;
  }
  .land {
    // position: absolute;
    @include mx.rect(460px, 40px, var(--land-color-1), 20px 20px 5px 5px);
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%) scale(1);
    z-index: 2;
    border-bottom: 5px solid var(--land-color-2);
  }
  .grass {
    background-color: transparent;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);

    @for $i from 0 to 2 {
      &-#{$i + 1} {
        z-index: $i + 1;
        width: #{20 * (3 - $i)}px;
        height: #{10 * (3 - $i)}px;
        border-radius: #{10 * (3 - $i)}px #{10 * (3 - $i)}px 0 0;
      }
    }

    &-1 {
      box-shadow: -90px 0 0 0 var(--grass-color-1),
        -130px 4px 0 -4px var(--grass-color-1),
        -165px 8px 0 -8px var(--grass-color-1), 90px 0 0 0 var(--grass-color-1),
        140px 4px 0 -4px var(--grass-color-1),
        165px 8px 0 -8px var(--grass-color-1);
    }
    &-2 {
      box-shadow: -90px 0 0 0 var(--grass-color-2),
        -60px 2px 0 -2px var(--grass-color-2),
        -35px 5px 0 -5px var(--grass-color-2), 90px 0 0 0 var(--grass-color-2),
        60px 2px 0 -2px var(--grass-color-2),
        35px 5px 0 -5px var(--grass-color-2);
    }
  }
  .windmill {
    @include mx.wh(180px, 280px);
    left: 50%;
    bottom: 80px;
    transform: translateX(-50%);
    z-index: 2;
    @include mx.pseudo-ba();
    &::before {
      top: 0;
      left: 50%;
      transform: translateX(-50%);
      @include mx.rect(
        130px,
        30px,
        var(--mill-top-color),
        0 0 20px 20px / 0 0 45px 45px
      );
    }
    &::after {
      @include mx.wh(100%, 50px);
      bottom: 0;
      background: linear-gradient(
        to bottom,
        var(--mill-bottom-color-1) 25px,
        var(--mill-bottom-color-2) 25px,
        var(--mill-bottom-color-2) 45px,
        var(--mill-bottom-color-1) 45px
      );
    }
    .window {
      left: 50%;
      top: 30%;
      transform: translate(-50%, -50%);
      @include mx.rect(8px, 8px, transparent);
      box-shadow: 5px 25px 0 0 var(--window-color-2),
        -5px 25px 0 0 var(--window-color-2), 5px 35px 0 0 var(--window-color-2),
        -5px 35px 0 0 var(--window-color-2), 0 30px 0 5px var(--window-color-1),
        0 30px 0 8px var(--window-color-3), 5px -25px 0 0 var(--window-color-2),
        -5px -25px 0 0 var(--window-color-2),
        5px -35px 0 0 var(--window-color-2),
        -5px -35px 0 0 var(--window-color-2),
        0 -30px 0 5px var(--window-color-1), 0 -30px 0 8px var(--window-color-3);
    }
    .pillar {
      @include mx.wh(100%, 200px);
      bottom: 50px;
      background-image: linear-gradient(
          335deg,
          var(--brick-color-2) 6px,
          transparent 6px
        ),
        linear-gradient(155deg, var(--brick-color-2) 6px, transparent 6px),
        linear-gradient(335deg, var(--brick-color-2) 6px, transparent 6px),
        linear-gradient(155deg, var(--brick-color-2) 6px, transparent 6px);
      background-size: 15px 15px;
      background-position: 0 0, 2px 9px, 7px 8px, 9px 1px;
      background-color: var(--brick-color-1);
      clip-path: polygon(20% 0, 80% 0, 100% 100%, 0 100%);
      box-shadow: inset 0 4px 0 0 var(--wood-color-1);
    }
    .dome {
      @include mx.rect(110px, 65px, var(--dome-color), 55px 55px 0 0);
      left: 50%;
      transform: translateX(-50%);
      top: -65px;
      &-window {
        @include mx.wh(24px, 26px);
        border-radius: 12px 12px 0 0;
        background: linear-gradient(
            to right,
            transparent 8px,
            var(--window-color-1) 8px,
            var(--window-color-1) 10px,
            transparent 10px
          ),
          linear-gradient(
            to bottom,
            transparent 9px,
            var(--window-color-1) 9px,
            var(--window-color-1) 11px,
            transparent 11px
          ),
          var(--window-color-2);
        bottom: 10px;
        left: 50%;
        transform: translateX(-50%);
        border: 3px solid var(--window-color-1);
        &::before {
          @include mx.pseudo();
          @include mx.rect(32px, 2px, var(--window-color-1));
          bottom: -4px;
          left: 50%;
          transform: translateX(-50%);
          box-shadow: 0 2px 0 0 var(--wood-color-1);
        }
      }
    }
    .blades {
      z-index: -1;
      @include mx.rect(20px, 20px, var(--wood-color-3), 50%);
      left: 44%;
      top: -12%;
      transform: translate(-50%, -50%) rotate(40deg);
      animation: blades-spin var(--blades-spin-time) linear infinite;
      .blade {
        @include mx.rect(200px, 60px, var(--blade-color-1));
        left: 60px;
        top: -5px;
        transform-origin: -50px 15px;
        transform: rotate(0);
        box-shadow: 0 5px 0 0 var(--blade-color-2),
          0 -5px 0 0 var(--blade-color-2);
        @include mx.pseudo-ba();
        &::before {
          @include mx.rect(260px, 8px, var(--wood-color-2), 5px);
          top: 11px;
          left: -55px;
        }
        &::after {
          @include mx.rect(4px, 75px, var(--wood-color-1), 2px);
          left: 50%;
          top: 50%;
          transform: translate(-50%, -50%);
          box-shadow: -33px 0 0 0 var(--wood-color-1),
            -67px 0 0 0 var(--wood-color-1), -100px 0 0 0 var(--wood-color-1),
            33px 0 0 0 var(--wood-color-1), 67px 0 0 0 var(--wood-color-1),
            100px 0 0 0 var(--wood-color-1);
        }

        @for $i from 0 to 4 {
          &-#{$i + 1} {
            transform: rotate(#{90 * $i}deg);
          }
        }
      }
    }
    .ramp {
      @include mx.wh(240px, 35px);
      bottom: 40px;
      left: 50%;
      transform: translateX(-50%);
      background: linear-gradient(
          to bottom,
          transparent 10px,
          var(--wood-color-4) 10px,
          var(--wood-color-4) 15px,
          transparent 15px
        ),
        linear-gradient(
          to right,
          var(--wood-color-1) 32%,
          var(--wood-color-2) 32%,
          var(--wood-color-2) 66%,
          var(--wood-color-3) 66%
        );
      z-index: 2;
      border-radius: 5px;
      &::before {
        @include mx.pseudo();
        @include mx.rect(20px, 5px, transparent);
        top: 10px;
        left: 50%;
        transform: translateX(-50%);
        box-shadow: -115px 0 0 0 var(--sky-color-2),
          115px 0 0 0 var(--sky-color-1);
      }
      .grill {
        @include mx.rect(6px, 25px, transparent, 2px 2px 0 0);
        left: 50%;
        transform: translateX(-50%);
        top: -25px;
        box-shadow: -100px 0 0 0 var(--wood-color-1),
          -60px 0 0 0 var(--wood-color-1), -20px 0 0 0 var(--wood-color-2),
          20px 0 0 0 var(--wood-color-2), 60px 0 0 0 var(--wood-color-3),
          100px 0 0 0 var(--wood-color-3);
        &::before {
          @include mx.pseudo();
          @include mx.wh(240px, 6px);
          background: linear-gradient(
            to right,
            var(--wood-color-2) 33%,
            var(--wood-color-3) 33%,
            var(--wood-color-3) 66%,
            var(--wood-color-4) 66%
          );
          top: 6px;
          left: 50%;
          transform: translateX(-50%);
          border-radius: 2px;
        }
      }
      .hook {
        @include mx.wh(8px, 24px);
        bottom: -24px;
        transform-origin: 0 0;
        @include mx.pseudo-ba();
        &::before {
          @include mx.wh(8px, 10px);
          background: var(--mill-bottom-color-1);
          bottom: 0;
          transform: skew(-50deg);
        }
        &::after {
          @include mx.rect(8px, 10px, inherit);
          bottom: 0;
        }

        $hooks: 2, 1, -1, -2;
        @each $hook in $hooks {
          $i: index($hooks, $hook);
          &-#{$i} {
            background: var(--wood-color-#{$i});
            left: #{(32.5% * ($i - 1)) + $hook};
            transform: skew(#{25 * $hook}deg);
            &::before {
              right: #{-2.5 * $hook}px;
              transform: skew(#{-25 * $hook}deg);
            }
          }
        }
      }
    }
  }
  .sun {
    @include mx.rect(140px, 140px, var(--sun-color), 50%);
    right: 0;
    top: 80px;
  }
}

@keyframes blades-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(1turn);
  }
}
